<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>帮帮网-注册</title>
<link href="../CSS/formStyle.css" rel="stylesheet"  type="text/css" />
<style type="text/css">

</style>
<script type="text/javascript" src="../JS/prototype.js"></script>
<script type="text/javascript" src="../JS/httpRequest.js"></script>
<script type="text/javascript" >
function Register()
{
	
	if(CheckUsername() && CheckPwd() && CheckPwd2() && CheckQQ() && CheckCellphone() )
	{
	  var username=$('txtUsername').value;
	  var pwd=$('txtPwd').value;
	  var qq=$('QQ').value;
	  var cellphone=$('cellphone').value;
	  var sex = $('sex').value;
	  var emot = $('emot').value;
	  var college = $('college').value;
	  var regbirthyear=$('regbirthyear').value;
	  var regbirthmonth=$('regbirthmonth').value;
	  var regbirthday=$('regbirthday').value;

	  alert("name:"+username);
	  alert("pwd:"+pwd);
	  alert("qq:"+qq);
	  alert("cellphone:"+cellphone);
	  alert("sex:"+sex);
	  alert("college:"+college);
	  alert("year:"+regbirthyear);
	  alert("month:"+regbirthmonth);
	  alert("day:"+regbirthday);

	  var url="user.php?action=AddUser";	  
	  var para="username="+username;
	  para+="&password="+pwd;	
	  para+="&qq="+qq;
	  para+="&cellphone="+cellphone;
	  para+="&sex="+sex;
	  para+="&emot="+emot;
	  para+="&college="+college;	  
	  para+="&year="+regbirthyear;
	  para+="&month="+regbirthmonth;
	  para+="&day="+regbirthday;
	  response=SendPostRequest(url,para); 	  
	  alert(response);
	  //跳转到首页
	  window.location.href="../index.htm";
	}
	  
	  
}
function CheckUsername()
{
	var txtUsername=document.getElementById('txtUsername');
	var username=txtUsername.value;
	if(username==null ||username=="")
	{
		$('nameWarn').innerHTML="用户名不能为空!";
		return false ;
	}
	else
	{
	  var url="user.php?action=CheckUser";	  
	  var para="username="+username;
	  response=SendPostRequest(url,para); 	
	  if(response=="false")
	  {
		 $('nameWarn').innerHTML="用户名已存在，请用其他用户名!";
		 return false ;
	  }
	  else
	  {
		  $('nameWarn').innerHTML="ok";
		   return true;
	  }
	 
	  
	}
}

function CheckPwd()
{
	var pwd=document.getElementById('txtPwd').value;
	if(pwd==null || pwd=="")
	{
		$('pwdWarn').innerHTML="密码不能为空!";
		return false ;
	}
	else
	{
		$('pwdWarn').innerHTML="ok";
	    return true;
	}
}

function CheckPwd2()
{
	var pwd=document.getElementById('txtPwd').value;
	var pwd2=document.getElementById('txtPwd2').value;
	if(pwd2==null || pwd2=="")
	{	
	   $('pwd2Warn').innerHTML="密码不能为空!";	
		return false;
	}
	if(pwd2!=pwd)
	{	
	   $('pwd2Warn').innerHTML="密码不一致!";	
		return false;
	}
	else
	{
		$('pwd2Warn').innerHTML="ok";
		return true;
	}
	
}
function CheckQQ()
{
	var QQ=document.getElementById('QQ').value;
    var patrn=/^[0-9]{1,20}$/;
	if(QQ==null)
	{
		$('QQWarn').innerHTML="请输入qq号!";	
		return false;		
	}
    else if(!patrn.exec(QQ))
    {
		$('QQWarn').innerHTML="请输入正确的qq号!";
		return false;
    } 
	else
	{
		$('QQWarn').innerHTML="OK!";
		return true;	
	}
}

function CheckCellphone()
{
	var phone=document.getElementById('cellphone').value;
	//alert(phone.length);
    var patrn=/^[0-9]{1,20}$/;
	if(phone==null)
	{
		$('cellphoneWarn').innerHTML="请输入手机号码!";	
		return false;		
	}
    else if(!patrn.exec(phone))
    {
		$('cellphoneWarn').innerHTML="请输入正确的手机号码!";
		return false;
    } 
    else if(phone.length!=11)
    {
		$('cellphoneWarn').innerHTML="朋友 手机号码 应该是11位吧";
		return false;
    } 
	else
	{
		$('cellphoneWarn').innerHTML="OK!";
		return true;	
	}
}
</script>
</head>

<body>
<div>免费开通帮帮网账号</div>
<div>
  <table width="500" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="150">用户名：</td>
      <td width="150"><input type="text" id="txtUsername"  onblur="CheckUsername()" /></td>
      <td width="250" class="warning" id="nameWarn">*</td>
    </tr>
    <tr>
      <td>密码：</td>
      <td><input type="text" id="txtPwd" onblur="CheckPwd()"   /></td>
      <td id="pwdWarn" class="warning">*</td>
    </tr>
    <tr>
      <td  >确认密码：</td>
      <td ><input type="text" id="txtPwd2" onblur="CheckPwd2()" /></td>
      <td id="pwd2Warn" class="warning">*</td>
    </tr>
    <tr>
      <td  >学院：</td>
      <td >
			<select id=college>
			<option value=''></option>
		    <option value=电院 >电院</option>
		    <option value=机械 >机械</option>
	  	    <option value=化工 >化工</option>
		    <option value=软件 >软件</option>
			</select>
	  </td>
      <td id="collegeWarn" class="warning">*</td>
    </tr>
	<tr> 
		<td bgcolor=yellow> 您的QQ号码：</td>
		<td bgcolor=blue><input type=text size=20 maxlength=14 id='QQ' onblur="CheckQQ()"></td>
		<td id="QQWarn" class="warning"></td>
	</tr>
	<tr> 
		<td bgcolor=red> 您的手机号码：</td>
		<td bgcolor=$sa><input type=text size=20 maxlength=14 id='cellphone' onblur="CheckCellphone()"></td>
		<td id="cellphoneWarn" class="warning"></td>
	</tr>
	<tr> 
		<td bgcolor=$ffffffff> 您的性别:</td>
		<td bgcolor=$forumc1234ne>
		<select id='sex'>
		<OPTION value=1>男</OPTION>
		<OPTION value=2>女</OPTION>
		<OPTION value=0 selected>保密</OPTION>
		</select>
		</td>
	</tr>
	<tr> 
		<td bgcolor=$ffffffff> 情感状态:</td>
		<td bgcolor=$forumc1234ne>
		<select id='emot'>
		<OPTION value=1>单身</OPTION>
		<OPTION value=2>恋爱</OPTION>
		<OPTION value=0 selected>保密</OPTION>
		</select>
		</td>
	</tr>
	<tr> 
		<td bgcolor=hellokitty> 你的生日:</td>
		<td bgcolor=mua日你妹>
		<select id=regbirthyear>
			<option value=''></option> 
			<option value=1947 >1947</option>  
			<option value=1948 >1948</option>  
			<option value=1949 >1949</option>  
			<option value=1950 >1950</option>  
			<option value=1951 >1951</option>  
			<option value=1952 >1952</option>  
			<option value=1953 >1953</option>  
			<option value=1954 >1954</option>  
			<option value=1955 >1955</option>  
			<option value=1956 >1956</option>  
			<option value=1957 >1957</option>  
			<option value=1958 >1958</option>  
			<option value=1959 >1959</option>  
			<option value=1960 >1960</option>  
			<option value=1961 >1961</option>  
			<option value=1962 >1962</option>  
			<option value=1963 >1963</option>  
			<option value=1964 >1964</option>  
			<option value=1965 >1965</option>  
			<option value=1966 >1966</option>  
			<option value=1967 >1967</option>  
			<option value=1968 >1968</option>
			<option value=1969 >1969</option>
			<option value=1970 >1970</option>
			<option value=1971 >1971</option>
			<option value=1972 >1972</option>
			<option value=1973 >1973</option>
			<option value=1974 >1974</option>
			<option value=1975 >1975</option>
			<option value=1976 >1976</option>
			<option value=1977 >1977</option>
			<option value=1978 >1978</option>
			<option value=1979 >1979</option>
			<option value=1980 >1980</option>
			<option value=1981 >1981</option>
			<option value=1982 >1982</option>
			<option value=1983 >1983</option>
			<option value=1984 >1984</option>
			<option value=1985 >1985</option>
			<option value=1986 >1986</option>
			<option value=1987 >1987</option>
			<option value=1988 >1988</option>
			<option value=1989 >1989</option>
			<option value=1990 >1990</option>
			<option value=1991 >1991</option>
			<option value=1992 >1992</option>
			<option value=1993 >1993</option>
			<option value=1994 >1994</option>
			<option value=1995 >1995</option>
			<option value=1996 >1996</option>
			<option value=1997 >1997</option>
			<option value=1998 >1998</option>
			<option value=1999 >1999</option>
			<option value=2000 >2000</option>
			</select>年 
			<select id=regbirthmonth>
			<option value=''></option>
		    <option value=1 >1</option>
		    <option value=2 >2</option>
	  	    <option value=3 >3</option>
		    <option value=4 >4</option>
		    <option value=5 >5</option>
		    <option value=6 >6</option>
		    <option value=7 >7</option>
		    <option value=8 >8</option>
		    <option value=9 >9</option>
		    <option value=10 >10</option>
			<option value=11 >11</option>
			<option value=12 >12</option>
			</select>月 
			<select id=regbirthday>
			<option value=''></option>
			<option value=1 >1</option>
			<option value=2 >2</option>
			<option value=3 >3</option>
			<option value=4 >4</option>
			<option value=5 >5</option>
			<option value=6 >6</option>
			<option value=7 >7</option>
			<option value=8 >8</option>  
			<option value=9 >9</option>  
			<option value=10 >10</option>  
			<option value=11 >11</option>  
			<option value=12 >12</option>  
			<option value=13 >13</option>  
			<option value=14 >14</option>  
			<option value=15 >15</option>  
			<option value=16 >16</option>  
			<option value=17 >17</option>  
			<option value=18 >18</option>  
			<option value=19 >19</option>  
			<option value=20 >20</option>  
			<option value=21 >21</option>  
			<option value=22 >22</option>  
			<option value=23 >23</option>  
			<option value=24 >24</option>  
			<option value=25 >25</option>  
			<option value=26 >26</option>  
			<option value=27 >27</option>  
			<option value=28 >28</option>  
			<option value=29 >29</option>  
			<option value=30 >30</option>  
			<option value=31 >31</option>
		</select>日</font>
		</td>
	</tr>
    <tr>
      <td colspan="2"  align="center"><input type="button" id="btnRegister" value="立即注册" onclick="Register()" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</div>
</body>
</html>
